#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	int n,l,r;
	cin>>n>>l>>r;
	if(l<n)
	  l=n;
	int k=l%n;
	if(l+n-k-1<=r)
	  cout<<n-1;
	else{
		cout<<k+r-l;
	}
	return 0;
}
